package ch10;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.util.Scanner;

public class LineNumberer {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws MalformedURLException 
	 */
	public static void main(String[] args) throws MalformedURLException, IOException
	{
		//Prompt for the input and output file.		
		Scanner console = new Scanner(System.in);
		System.out.println("Input file:");
		String inputFileName = console.next();
		System.out.println("Output file:");
		String outputFileName = console.next();
		
		//Construct the Scanner and PrintWriter objects for reading and writing.		
		File inputFile = new File(inputFileName);
		Scanner in = new Scanner(inputFile);
		//Scanner in = new Scanner(new URL("http://petertolstrup.com").openStream());
		PrintWriter out = new PrintWriter(outputFileName);
		int lineNumber = 1;
		
		//Read the input and write the output:
		while(in.hasNextLine())
		{
			String line = in.nextLine();
			out.println("/* " + lineNumber + " */" + line);
			lineNumber++;
		}
		
		//Close streams
		in.close();
		out.close();
		

	}

}
